package main

import (
	"fmt"
	"os"
	"path/filepath"

	"gitee.com/gousing/config"
)

// config> go run testing/main.go
func main() {
	curPath, err := os.Getwd()
	if err != nil {
		fmt.Println("Error getting current directory:", err)
		return
	}
	fmt.Println("Current directory:", curPath)

	file := filepath.Join(curPath, "test_package/1.toml")
	fmt.Println("load config file", file)
	if err := config.LoadFromFiles(file); err != nil {
		panic(err)
	}
	if !config.IsSet("ValString") {
		panic("IsSet: ValString not set")
	}
	if config.GetString("ValString") != "Apple" {
		panic("GetString: ValString not equal")
	}
	if !config.InConfig("ValString") {
		panic("InConfig: ValString not in config")
	}
	config.RegisterAlias("ValString", "ValStringAlias")
	if !config.InConfig("ValStringAlias") {
		panic("InConfig: ValStringAlias not in config")
	}
	if config.GetString("ValStringAlias") != "Apple" {
		panic("GetString: ValStringAlias not equal")
	}
}
